package com.wzq.solution;

class Solution1052 {
    public static int maxSatisfied(int[] customers, int[] grumpy, int x) {
        int sum = 0, len = customers.length;
        for (int i = 0; i < len; i++) {
            if (grumpy[i] == 0){
                sum += customers[i];
                customers[i] = 0;
            } 
        }
        int num = customers[0];
        int maxval = customers[0];
        for (int i = 1; i < len; i++){
            if (i < x) num = num + customers[i];
            else num = num + customers[i] - customers[i - x];
            maxval = Math.max(maxval, num);
        }
        
        return (sum + maxval);
    }


    public static void main(String[] args) {
        int[] customers = new int[]{10,1,7};
        int[] grumpy = new int[]{0,0,0};
        maxSatisfied(customers,grumpy,2);
    }
}